
///引入实列
import { instance, requestMock } from "@/util/http";
//三级列表请求函数
export const requestCategoryList = () => {
  return instance.get("/api/product/getBaseCategoryList")
}

//请求轮播图banner函数
export const requestBannerList = () => {
  return requestMock.get("/banner")
};
//请求楼层函数
export const requestFloorList = () => {
  return requestMock.get("/floor")
};

//请求搜索页数据
export const requestSearchList = (params) => {
  return instance.post("/api/list", params);
};
//请求商品页数据
/* get 请求 params传参  */
export const requestDetail = (skuId) => {
  return instance.get(`/api/item/${skuId}`);
};
//加入购物车
export const requestAddorUpdataNumCart = ({ skuId, skuNum }) => {
  return instance.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};
//获取购物车请求
export const requestShopCart = () => {
  return instance.get(`/api/cart/cartList`);
};

//对购物车数量进行改动
export const requestShopCartCount = (skuId, skuNum) => {
  return instance.post(`/api/cart/addToCart/${skuId}/${skuNum}`);
};
//修改单个商品的选中状态
export const requestUpdateSingleCheck = ({ skuId, isChecked }) => {
  return instance.get(`/api/cart/checkCart/${skuId}/${isChecked}`);
};


//修改所有购物车商品的选中状态
export const requestUpdateAllCheck = (isChecked, skuIdList) => {
  return instance.post(`/api/cart/batchCheckCart/${isChecked}`, skuIdList);
};
//删除购物车单个商品
export const requestDeleteSingleGood = (skuId) => {
  return instance.delete(`/api/cart/deleteCart/${skuId}`);
};
//删除所有的购物车商品
export const requestDeleteAllGoods = (skuIdList) => {
  return instance.delete(`/api/cart/batchDeleteCart`, {
    data: skuIdList,
  });
};

//获取注册验证码
export const requestgetRegisterCode = (phone) => {
  return instance.get(`/api/user/passport/sendCode/${phone}`);
};

//注册成功
export const requestRegisterSucess = (registerInfo) => {
  return instance.post(`/api/user/passport/register`, registerInfo);
};

//登录请求
export const requestLogin = (userInfo) => {
  return instance.post("/api/user/passport/login", userInfo);
};
//登录以后获取用户信息
export const requestUserInfo = () => {
  return instance.get("/api/user/passport/auth/getUserInfo");
};

//退出登录
export const requestLogout = () => {
  return instance.get("/api/user/passport/logout");
};

//交易页数据获取
export const requestTradeInfo = () => {
  return instance.get("/api/order/auth/trade");
};
//请求购物地址
export const requestTradeAddress = () => {
  return requestMock.get("/address");
};
//提交订单
export const requestAddTrade = (tradeNo, tradeInfo) => {
  return instance.post(
    `/api/order/auth/submitOrder?tradeNo=${tradeNo}`,
    tradeInfo
  );
};

//根据订单号获取订单详细信息
export const requestPayDetail = (orderId) => {
  return instance.get(`/api/payment/weixin/createNative/${orderId}`);
};
//查看某个订单编号的支付状态
export const requestPayStatus = (orderId) => {
  return instance.get(`/api/payment/weixin/queryPayStatus/${orderId}`);
};


//查看订单列表
export const requestOrderList = ({ page, limit }) => {
  return instance.get(`/api/order/auth/${page}/${limit}`);
};



